package com.mmall.concurrency.example.immutable;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;

import java.util.Collections;
import java.util.Map;

/**
 * <p>guava
 *
 * @author Diamon.Cheng
 * @date 2019/12/6.
 */
@Slf4j
public class ImmutableExample_2 {
    
    private static Map<Integer, Integer> map = Maps.newHashMap();
    
    static {
        map.put(1, 2);
        map.put(3, 4);
        map.put(5, 6);
        //unmodifiableMap修饰的变量是不可以被修改
        map = Collections.unmodifiableMap(map);
    }
    
    public static void main(String[] args) {
        map.put(1, 3);
        log.info("{}", map.get(1));
    }
}
